package com.znsd.zl.contract.utils;

import com.znsd.zl.contract.entity.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @ClassName: ContractTemplateQueryUtils
 * @Program: zlhouse-manage
 * @Description: 查询数据
 * @Author: tangjun
 * @Date: 2020-08-22 20:55
 * @Version 1.0
 **/
@Component
public class ContractTemplateQueryUtils {
	@Resource
	private ContractTemplateUtils contractTemplateUtilsl;


	/**
	 * @Author tangjun
	 * @Description 用于进行数据存储
	 * @Date  2020/8/23 0023
	 * @param userEntity 获取的用户数据
	 * @param houseEntity 房屋信息
	 * @param userEntity1 用户信息    房东
	 * @param template 获取的模板地址
	 * @return void
	 **/
	public String contractTemplaterQuery(UserEntity userEntity1, HouseEntity houseEntity,
	                                     UserEntity userEntity, ContractTemplateEntity template, ContractEntity contractEntity)  {
		// 模版文件
		String templateFilePath = template.getTemplateSite();
		// 保存PDF文件
		String pdfFilePath = "zlhouse-contract/src/main/resources/static/file/aa.pdf";
		// 表单数据
		HashMap<String,String> data = new HashMap<>(40);
		data.put("LESSOR",userEntity.getName());
		data.put("LEASS",userEntity1.getName());
		data.put("FLOOR_S",houseEntity.getArea()+"");
		data.put("BEGIN_DATE",contractEntity.getBeginDate());
		data.put("END_DATE",contractEntity.getEndDate());
		data.put("MONEY",houseEntity.getRentPrice()+"");
		data.put("LESSOR_PHONE",userEntity.getPhone());
		data.put("LEASS_PHONE",userEntity1.getPhone());
		data.put("EXACT_TIME",contractEntity.getExactTime());
		// 图片数据
		HashMap<String,String> imageData = new HashMap<>(51);
		imageData.put("ying","https://me-file.oss-cn-shenzhen.aliyuncs.com/upload/20200908/a7f977f068ab4beba1f1586316030f42.gif");

		// 根据PDF模版生成PDF文件
		return contractTemplateUtilsl.createPdf(templateFilePath,data,imageData,true,pdfFilePath);
	}


	/**
	 * @Author tangjun
	 * @Description 用于进行数据存储
	 * @Date  2020/8/23 002
	 * @param houseEntity 房屋信息
	 * @param userEntity 获取的用户数据
	 * @param entitye 房东数据
	 * @param contractEntity 合同数据
	 * @return void
	 **/
	public String contractTemplaterAdmin(HouseEntity houseEntity, UserEntity userEntity, UserEntity entitye, ContractEntity contractEntity) {
		// 模版文件
		String templateFilePath = contractEntity.getTemplate();
		// 保存PDF文件
		String pdfFilePath = "zlhouse-contract/src/main/resources/static/file/aa.pdf";
		// 表单数据
		HashMap<String,String> data = new HashMap<>(75);
		data.put("LESSOR",entitye.getName());
		data.put("LEASS",userEntity.getName());
		data.put("FLOOR_S",houseEntity.getArea()+"");
		data.put("BEGIN_DATE",contractEntity.getBeginDate());
		data.put("END_DATE",contractEntity.getEndDate());
		data.put("MONEY",houseEntity.getRentPrice()+"");
		data.put("LESSOR_PHONE",entitye.getPhone());
		data.put("LEASS_PHONE",userEntity.getPhone());
		data.put("EXACT_TIME",contractEntity.getExactTime());
		// 图片数据
		HashMap<String,String> imageData = new HashMap<>(86);
		imageData.put("ying","https://me-file.oss-cn-shenzhen.aliyuncs.com/upload/20200908/a7f977f068ab4beba1f1586316030f42.gif");

		// 根据PDF模版生成PDF文件
		return contractTemplateUtilsl.createPdf(templateFilePath,data,imageData,true,pdfFilePath);
	}


	/**
	 * @Author tangjun
	 * @Description 修改数据
	 * @Date  2020/8/23 002
	 * @param houseEntity 房屋信息
	 * @param userEntity 获取的用户数据
	 * @param entitye 房东数据
	 * @param contractEntity 合同数据
	 * @return void
	 **/
	public String contractTemplaterUpdateAdmin(HouseEntity houseEntity, UserEntity userEntity, UserEntity entitye, ContractQueryEntity contractEntity) {
		// 模版文件
		String templateFilePath = contractEntity.getTemplate();
		// 保存PDF文件
		String pdfFilePath = "zlhouse-contract/src/main/resources/static/file/aa.pdf";
		// 表单数据
		HashMap<String,String> data = new HashMap<>(110);
		System.out.println(entitye.getName());
		System.out.println(userEntity.getName());
		data.put("LESSOR",entitye.getName());
		data.put("LEASS",userEntity.getName());
		data.put("FLOOR_S",houseEntity.getArea()+"");
		data.put("BEGIN_DATE",contractEntity.getBeginDate());
		data.put("END_DATE",contractEntity.getEndDate());
		data.put("MONEY",houseEntity.getRentPrice()+"");
		data.put("LESSOR_PHONE",entitye.getPhone());
		data.put("LEASS_PHONE",userEntity.getPhone());
		data.put("EXACT_TIME",contractEntity.getExactTime());
		// 图片数据
		HashMap<String,String> imageData = new HashMap<>(123);
		imageData.put("ying","https://me-file.oss-cn-shenzhen.aliyuncs.com/upload/20200908/a7f977f068ab4beba1f1586316030f42.gif");

		// 根据PDF模版生成PDF文件
		return contractTemplateUtilsl.createPdf(templateFilePath,data,imageData,true,pdfFilePath);
	}
}
